;=============================================================================== ; ; This is the actual script used by Pinnacle Software to validate the ; OutCSV command. You can view it whenever you need some examples of ; OutCSV usage. ; ; To try out this script, use any text input file -- it only reads the ; first line. The output (when everything is working fine) is simply ; a tidy series of sample output styles. ; ;=============================================================================== ; Configuration section ;=============================================================================== Config $CfgEnableOptionX = 'N' $CfgEnableOptionY = 'N' $CfgEnableOptionZ = 'N' $CfgCopyright = 'Copyright © 2004, 2005 by Pinnacle Software' $CfgVersion = '2.00.00' $CfgProgrammer = 'Timothy Campbell' $CfgEmail = 'info@parse-o-matic.com' $CfgLicense = 'This script may be used, at no charge, with any ' >> 'script-enabled Parse-O-Matic application, subject to any additional ' >> 'licensing requirements of such application.' End ;=============================================================================== ; FileInit ;=============================================================================== FileInit Error = '^^^^^^^^^ ERROR ' Error = Padded Error 80 'Right' '^' Sep1 = Padded '' 80 'Left' '=' OutEnd Sep1 Label = 'OutCSV Exercise Script' Label = Padded Label 80 'Center' ' ' OutEnd Label OutEnd Sep1 End ;------------------------------------------------------------------------------- ; Standard OutCSV usage (quoted) ;------------------------------------------------------------------------------- Output '[SAMPLE 01] ' OutCSV '' 'Init' OutCSV 'One' OutCSV 'Two' OutCSV 'Three' OutCSV '' 'Done' If $OutCSVRec <> '"One","Two","Three"' OutEnd Error ;------------------------------------------------------------------------------- ; Standard OutCSV usage (unquoted) ;------------------------------------------------------------------------------- Output '[SAMPLE 02] ' OutCSV '' 'Init' OutCSV 'One' 'Unquoted' OutCSV 'Two' 'Unquoted' OutCSV 'Three' 'Unquoted' OutCSV '' 'Done' If $OutCSVRec <> 'One,Two,Three' OutEnd Error ;------------------------------------------------------------------------------- ; Standard OutCSV usage (nulls, quoted, unquoted) ;------------------------------------------------------------------------------- Output '[SAMPLE 03] ' OutCSV '' 'Init' OutCSV 3 'Null' OutCSV 5.5 'Unquoted' OutCSV 'Quoted' MyVar = 1 OutCSV MyVar 'Null' OutCSV '' 'Null' ; This will be ignored OutCSV 'Quoted' 'Quoted' OutCSV '1' 'Null' OutCSV '' 'Done' If $OutCSVRec <> ',,,5.5,"Quoted",,"Quoted",' OutEnd Error ;------------------------------------------------------------------------------- ; MinWidth ;------------------------------------------------------------------------------- Output '[SAMPLE 04] ' OutCSV 'MinWidth 5' 'Control' OutCSV '' 'Init' OutCSV '3' 'Null' OutCSV 5.5 'Unquoted' OutCSV 'Quoted' OutCSV '1' 'Null' OutCSV 'Quoted' 'Quoted' OutCSV '1' 'Null' OutCSV '' 'Done' If $OutCSVRec <> ' , , , 5.5,"Quoted", ,"Quoted", ' >> OutEnd Error ;------------------------------------------------------------------------------- ; MinWidth and MaxWidth ;------------------------------------------------------------------------------- Output '[SAMPLE 05] ' OutCSV 'MinWidth 5' 'Control' OutCSV 'MaxWidth 6' 'Control' OutCSV '' 'Init' OutCSV '3' 'Null' OutCSV 5.5 'Unquoted' OutCSV 'Quoted' OutCSV '1' 'Null' OutCSV 'Quoted' 'Quoted' OutCSV '1' 'Null' OutCSV '' 'Done' If $OutCSVRec <> ' , , , 5.5,"Quot", ,"Quot", ' >> OutEnd Error ;------------------------------------------------------------------------------- ; Changing MinWidth and MaxWidth after the Init ;------------------------------------------------------------------------------- Output '[SAMPLE 06] ' OutCSV 'MinWidth 5' 'Control' OutCSV 'MaxWidth 5' 'Control' OutCSV '' 'Init' OutCSV '3' 'Null' OutCSV 5.5 'Unquoted' OutCSV 'Quoted' OutCSV '1' 'Null' OutCSV 'MinWidth 5' 'Control' OutCSV 'MaxWidth 8' 'Control' OutCSV 'Quoted' 'Quoted' OutCSV '1' 'Null' OutCSV '' 'Done' If $OutCSVRec <> ' , , , 5.5,"Quo", ,"Quoted", ' >> OutEnd Error ;------------------------------------------------------------------------------- ; Alternative separator string (space, vertical bar, space) ;------------------------------------------------------------------------------- Output '[SAMPLE 07] ' OutCSV 'MinWidth 5' 'Control' OutCSV 'MaxWidth 5' 'Control' OutCSV ' | ' 'Init' ; Alternative separator string for this section only OutCSV '3' 'Null' OutCSV 5.5 'Unquoted' OutCSV 'Quoted' OutCSV '1' 'Nulls' OutCSV 'MinWidth 8' 'Control' OutCSV 'MaxWidth 8' 'Control' OutCSV 'Quoted' 'Quoted' OutCSV '1' 'Null' OutCSV '' 'Done' If $OutCSVRec <> >> ' | | | 5.5 | "Quo" | | "Quoted" | ' >> OutEnd Error ;------------------------------------------------------------------------------- ; QuoteChar None ;------------------------------------------------------------------------------- Output '[SAMPLE 08] ' OutCSV 'MinWidth 3' 'Control' OutCSV 'MaxWidth 3' 'Control' OutCSV 'QuoteChar None' 'Control' ; QuoteChar set to None (i.e. nothing) OutCSV '||' 'Init' OutCSV 1 'Null' OutCSV 'BB' 'Unquoted' OutCSV 'CC' 'Quoted' OutCSV 'DD' 'Unquoted' OutCSV 'EE' 'Unquoted' OutCSV '' 'Done' If $OutCSVRec <> ' || BB||CC || DD|| EE' OutEnd Error ;------------------------------------------------------------------------------- ; Separator None ;------------------------------------------------------------------------------- Output '[SAMPLE 09] ' OutCSV 'MinWidth 3' 'Control' OutCSV 'MaxWidth 3' 'Control' OutCSV 'QuoteChar None' 'Control' ; QuoteChar set to None (i.e. nothing) OutCSV 'None' 'Init' ; Set separator to 'None' ('Null' also works) OutCSV '1' 'Null' OutCSV 'BB' 'Unquoted' OutCSV 'CC' 'Quoted' OutCSV 'DD' 'Unquoted' OutCSV 'EE' 'Unquoted' OutCSV '' 'Done' If $OutCSVRec <> ' BBCC DD EE' OutEnd Error ;------------------------------------------------------------------------------- ; Resetting Controls settings back to normal and turn fields on and off ;------------------------------------------------------------------------------- Output '[SAMPLE 10] ' OutCSV 'MinWidth 0' 'Control' ; Reset MinWidth OutCSV 'MaxWidth 0' 'Control' ; Reset MaxWidth OutCSV 'QuoteChar "' 'Control' ; Reset QuoteChar to standard OutCSV '' 'Init' ; Separator back to standard (i.e. comma) OutCSV 'This' OutCSV 'and' OutCSV 'ERROR-A' '-Unquoted' OutCSV 'that' '+' OutCSV 'ERROR-B' '-' OutCSV 'ERROR-C' '-' OutCSV 'etcetera' '+Quoted' OutCSV '' 'Done' If $OutCSVRec <> '"This","and","that","etcetera"' OutEnd Error ;------------------------------------------------------------------------------- ; Quote-State Redefinition ;------------------------------------------------------------------------------- Output '[SAMPLE 11] ' OutCSV '' 'Init' OutCSV 1 OutCSV 2 'Unquoted...' ; Redefining the default quoting state OutCSV 3 OutCSV 'ERROR-A' '-' ; Turning fields off OutCSV 'ERROR-B' OutCSV 'A' '+Quoted...' ; Fields back on, and restoring the usual quote-state OutCSV 'B' OutCSV '' 'Done' If $OutCSVRec <> '"1",2,3,"A","B"' OutEnd Error ;------------------------------------------------------------------------------- ; Stop ;------------------------------------------------------------------------------- Output '[SAMPLE 12] ' OutCSV 'QuoteChar None' 'Control' OutCSV ' ' 'Init' OutCSV 1 OutCSV 2 OutCSV 3 OutCSV 'A' OutCSV 'B' OutCSV '' 'Stop' OutEnd $OutCSVRec If $OutCSVRec <> '1 2 3 A B' OutEnd Error ;------------------------------------------------------------------------------- ; SetWidth, Separator and concatenation of additional values ;------------------------------------------------------------------------------- Output '[SAMPLE 13] ' OutCSV 'QuoteChar Null' 'Control' ; Same as QuoteChar None OutCSV 'Separator | ' 'Control' ; New default separator: space-line-space OutCSV 'SetWidth 5' 'Control' ; Set both MinWidth and MaxWidth OutCSV '' 'Init' OutCSV 1 OutCSV 'QuoteChar "' 'Control' OutCSV 2 OutCSV 'QuoteChar None' 'Control' OutCSV 1 'Unquoted' 2 3 ; Concatenation of additional values OutCSV 'A' '' 'B' 'C' ; As above; note second parm placeholder OutCSV '' 'Done' If $OutCSVRec <> '1 | "2 " | 123 | ABC ' OutEnd Error ;------------------------------------------------------------------------------- ; We only process one input line, so we're done ;------------------------------------------------------------------------------- Stop